package com.minelx.serverandclient.stream.divider;

import java.util.Iterator;

public class Generator<E> implements Iterator<E> {

	private final BytesConverter<E> converter;

	private final Divider divider;

	public Generator(BytesConverter<E> converter, Divider divider) {
		this.divider = divider;
		this.converter = converter;
	}

	@Override
	public E next() {
		return converter.convert(divider.next(), divider.indexedCount());
	}

	@Override
	public boolean hasNext() {
		return divider.hasNext();
	}

	public interface BytesConverter<T> {
		// FIXME 2020/11/18  wait for me!!!   class Range(data start len)
		T convert(byte[] data, int len);
	}
}
